From edd64e79666991beedab7948ff9fd984e4e6baa3 Mon Sep 17 00:00:00 2001 From: Alastair Tse Date: Fri, 17 Nov 2006 17:57:49 +0000 Subject: [PATCH] [XEND] Accomodate extra "devices" in SXP that do not have DevControllers Signed-off-by: Alastair Tse --- tools/python/xen/xend/XendConfig.py | 10 ++++++---- tools/python/xen/xend/XendDevices.py | 5 +++++ tools/python/xen/xend/XendDomainInfo.py | 5 +++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tools/python/xen/xend/XendConfig.py b/tools/python/xen/xend/XendConfig.py index 1b0c58d316..ad5e0ad4a3 100644 --- a/tools/python/xen/xend/XendConfig.py +++ b/tools/python/xen/xend/XendConfig.py @@ -780,7 +780,8 @@ class XendConfig(dict): # Verify devices for d_uuid, (d_type, d_info) in self['device'].items(): - if d_type not in XendDevices.valid_devices(): + if d_type not in XendDevices.valid_devices() and \ + d_type not in XendDevices.pseudo_devices(): raise XendConfigError('Invalid device (%s)' % d_type) # Verify restart modes @@ -798,7 +799,8 @@ class XendConfig(dict): self['vtpm_refs'] = [] def device_add(self, dev_type, cfg_sxp = None, cfg_xenapi = None): - if dev_type not in XendDevices.valid_devices(): + if dev_type not in XendDevices.valid_devices() and \ + dev_type not in XendDevices.pseudo_devices(): raise XendConfigError("XendConfig: %s not a valid device type" % dev_type) @@ -917,8 +919,8 @@ class XendConfig(dict): if dev_type == 'pci': # special case for pci devices pci_devs.append(dev_info) else: - sxpr = self.device_sxpr(dev_type = dev_type, - dev_info = dev_info) + sxpr = self.device_sxpr(dev_type = dev_type, + dev_info = dev_info) sxprs.append((dev_type, sxpr)) # if we have any pci_devs, we parse them differently into diff --git a/tools/python/xen/xend/XendDevices.py b/tools/python/xen/xend/XendDevices.py index 4125cee2ae..2286824087 100644 --- a/tools/python/xen/xend/XendDevices.py +++ b/tools/python/xen/xend/XendDevices.py @@ -48,6 +48,11 @@ class XendDevices: return cls.controllers.keys() valid_devices = classmethod(valid_devices) + #@classmethod + def pseudo_devices(cls): + return ['console'] + pseudo_devices = classmethod(pseudo_devices) + #@classmethod def make_controller(cls, name, domain): """Factory function to make device controllers per domain. diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 7e91ac9bd0..295925d1da 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -1119,8 +1119,9 @@ class XendDomainInfo: @raise: VmError for invalid devices """ for (devclass, config) in self.info.all_devices_sxpr(): - log.info("createDevice: %s : %s" % (devclass, config)) - self._createDevice(devclass, config) + if devclass in XendDevices.valid_devices(): + log.info("createDevice: %s : %s" % (devclass, config)) + self._createDevice(devclass, config) if self.image: self.image.createDeviceModel() -- 2.30.2